cmake_minimum_required(VERSION 3.5)

project(WRTelemtry VERSION 0.1 LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets  Network WebSockets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network WebSockets)
#设置头文件路径
set(DIR_LOG ${CMAKE_CURRENT_SOURCE_DIR}/include/log4cpp
    DIR_JSON ${CMAKE_CURRENT_SOURCE_DIR}/include/json
    MOSQUITTO_DIRS  ${CMAKE_CURRENT_SOURCE_DIR}/include/mosquitto
)
#设置库文件路径
set(LIB_JSON ${CMAKE_CURRENT_SOURCE_DIR}/lib/json/libjsoncpp.a)
set(LIB_LOG ${CMAKE_CURRENT_SOURCE_DIR}/lib/log4cpp/liblog4cpp.a)
set(MOSQUITTO_LIBS ${CMAKE_CURRENT_SOURCE_DIR}/lib/mosquitto/libmosquitto.so)
#添加头文件路径
include_directories(
        ${CMAKE_CURRENT_SOURCE_DIR}
)
find_package(OpenCV REQUIRED)


set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
file(GLOB_RECURSE SRC_FILES  ${SRC_DIR}/player/images/*.cpp
        ${SRC_DIR}/player/images/*.h
        ${SRC_DIR}/control/keybordcontrol/*.cpp
        ${SRC_DIR}/control/keybordcontrol/*.h
        ${SRC_DIR}/interface/api/*.cpp
        ${SRC_DIR}/interface/api/*.h
        ${SRC_DIR}/interface/*.h
        ${SRC_DIR}/control/keybordcontrol/*.cpp
        ${SRC_DIR}/control/keybordcontrol/*.h
        ${SRC_DIR}/common/log/*.cpp
        ${SRC_DIR}/common/log/*.h
        ${SRC_DIR}/common/config/*.cpp
        ${SRC_DIR}/common/config/*.h
        ${SRC_DIR}/app/*.cpp
        ${SRC_DIR}/app/*.h
        ${SRC_DIR}/util/crc/*.cpp
        ${SRC_DIR}/util/crc/*.h
        ${SRC_DIR}/interface/form/*.ui
        ${SRC_DIR}/interface/form/*.h
        ${SRC_DIR}/interface/form/*.cpp
        ${SRC_DIR}/sigcmd/*.h
        ${SRC_DIR}/sigcmd*.cpp
        ${SRC_DIR}/util/*.h
        ${SRC_DIR}/util/*.cpp
)
include_directories(${OpenCV_INCLUDE_DIRS}
        ${DIR_JSON}
        ${DIR_LOG}
        ${MOSQUITTO_DIRS}

)
set(PROJECT_SOURCES
        main.cpp
        include/opencv2/opencv.hpp
        ${SRC_FILES}
        src/sigcmd/mqttclient.cpp


)

if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
    qt_add_executable(WRTelemtry
        MANUAL_FINALIZATION
        ${PROJECT_SOURCES}
    )
else()
    if(ANDROID)
        add_library(WRTelemtry SHARED
            ${PROJECT_SOURCES}
        )
# Define properties for Android with Qt 5 after find_package() calls as:
#    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
    else()
        add_executable(WRTelemtry
            ${PROJECT_SOURCES}
        )
    endif()
endif()

target_link_libraries(WRTelemtry PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt5::Network   ${LIB_LOG} ${LIB_JSON} ${MOSQUITTO_LIBS} ${OpenCV_LIBS}  Qt5::WebSockets -lpthread)

#暂时运行环境是
message("WestLake Robotics Platform: ${PROJECT_BINARY_DIR}")
message("OpenCV_LIBS is ${OpenCV_LIBS}")
file(COPY  ${CMAKE_CURRENT_SOURCE_DIR}/CFG DESTINATION ${PROJECT_BINARY_DIR})
